package br.com.mooble.utils;

import java.util.ArrayList;

import br.com.mooble.R;


import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DisciplinaAdapter extends BaseAdapter {

	private final Activity activity;
	private final ArrayList<String> disciplinas;
	private static LayoutInflater inflater = null;

	public DisciplinaAdapter(Activity a, ArrayList<String> disciplinas) {
		this.activity = a;
		this.disciplinas = disciplinas;
		inflater = (LayoutInflater) this.activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

	}

	public int getCount() {
		return this.disciplinas.size();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		if (convertView == null) {
			vi = inflater.inflate(R.layout.linha_tabela, null);
		}

		TextView nome = (TextView) vi.findViewById(R.id.tvNome); // title

		String d;
		d = this.disciplinas.get(position);

		nome.setText(d);
		return vi;
	}
}